﻿using CommonDevelop;
using CommonDevelop.Operator;
using CommonDevelop.Scene;

namespace WebWap
{
    /// <summary>
    /// 依赖项代理
    /// </summary>
    public class OperatorGetData : IOperatorGetData
    {
        private readonly IJwtFactory _jwtFactory;
        /// <summary>
        /// 构造
        /// </summary>
        public OperatorGetData(IJwtFactory jwtFactory)
        {
            this._jwtFactory = jwtFactory;
        }

        public UserInfo CheckLogin(string account, string password, out string errors)
        {
            errors = "用户账户没有取到相关数据";
            return null;
        }

        public UserInfo GetUserInfo(string userID, out string error)
        {
            error = "用户账户没有取到相关数据";
            return null;
        }

        public UserInfo UserInfoWith(UserInfo UI)
        {
            if (UI == null)
                return UI;

            if (string.IsNullOrWhiteSpace(UI.JWT_Token))
                UI.JWT_Token = this._jwtFactory.GenerateJWT(UI.Account, UI.Token, UI.UserId, UI.BusinessID).Result;

            return UI;
        }

        public void WriteLog(LogModel model)
        {

        }
    }
}
